#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    int hash1[26] = {0};
    int hash2[26] = {0};
    bool checkAlmostEquivalent(string word1, string word2)
    {
        for (int i = 0; i < word1.size(); ++i)
        {
            ++hash1[word1[i] - 'a'];
        }
        for (int i = 0; i < word2.size(); ++i)
        {
            ++hash2[word2[i] - 'a'];
        }
        for (int i = 0; i < 26; ++i)
        {
            if (abs(hash1[i] - hash2[i]) > 3)
            {
                return false;
            }
        }
        return true;
    }
};